package com.ruoyi.projectmanage.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projectmanage.domain.XzkProjectManage;
import com.ruoyi.projectmanage.service.IXzkProjectManageService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目管理Controller
 * 
 * @author ruoyi
 * @date 2021-04-02
 */
@Controller
@RequestMapping("/xzk/project_manage")
public class XzkProjectManageController extends BaseController
{
    private String prefix = "xzk/project_manage";

    @Autowired
    private IXzkProjectManageService xzkProjectManageService;

    @RequiresPermissions("xzk:project_manage:view")
    @GetMapping()
    public String project_manage()
    {
        return prefix + "/project_manage";
    }

    /**
     * 查询项目管理列表
     */
    @RequiresPermissions("xzk:project_manage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(XzkProjectManage xzkProjectManage)
    {
        startPage();
        List<XzkProjectManage> list = xzkProjectManageService.selectXzkProjectManageList(xzkProjectManage);
        return getDataTable(list);
    }

    /**
     * 导出项目管理列表
     */
    @RequiresPermissions("xzk:project_manage:export")
    @Log(title = "项目管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(XzkProjectManage xzkProjectManage)
    {
        List<XzkProjectManage> list = xzkProjectManageService.selectXzkProjectManageList(xzkProjectManage);
        ExcelUtil<XzkProjectManage> util = new ExcelUtil<XzkProjectManage>(XzkProjectManage.class);
        return util.exportExcel(list, "project_manage");
    }

    /**
     * 新增项目管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存项目管理
     */
    @RequiresPermissions("xzk:project_manage:add")
    @Log(title = "项目管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(XzkProjectManage xzkProjectManage)
    {
        return toAjax(xzkProjectManageService.insertXzkProjectManage(xzkProjectManage));
    }

    /**
     * 修改项目管理
     */
    @GetMapping("/edit/{projectid}")
    public String edit(@PathVariable("projectid") Long projectid, ModelMap mmap)
    {
        XzkProjectManage xzkProjectManage = xzkProjectManageService.selectXzkProjectManageById(projectid);
        mmap.put("xzkProjectManage", xzkProjectManage);
        return prefix + "/edit";
    }

    /**
     * 修改保存项目管理
     */
    @RequiresPermissions("xzk:project_manage:edit")
    @Log(title = "项目管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(XzkProjectManage xzkProjectManage)
    {
        return toAjax(xzkProjectManageService.updateXzkProjectManage(xzkProjectManage));
    }

    /**
     * 删除项目管理
     */
    @RequiresPermissions("xzk:project_manage:remove")
    @Log(title = "项目管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(xzkProjectManageService.deleteXzkProjectManageByIds(ids));
    }
}
